<?php 
	$selectors	     = getDefaultSelectors();
	$selectors_theme = getThemeSelectors($item['theme_type']);
	if($_REQUEST['type'] == 4)
	{ $selectors_com = getSelectorsComponent(); }
	if($_REQUEST['type'] == 5)
	{ $selectors_mod = getSelectorsModule(); }
	$type 			 = getThemeType($item['theme_type']);
	$style 			 = getThemeStylesheet($item['id']);
	
	if($_REQUEST['type'] < 1)
	{ $title = 'Theme Main Stylesheet'; }
	else
	{
		if($_REQUEST['type'] == 1)
		{ $title = 'Headers Override Style'; }
		if($_REQUEST['type'] == 2)
		{ $title = 'Footers Override Style'; }
		if($_REQUEST['type'] == 3)
		{ $title = 'Buttons Override Style'; }
		if($_REQUEST['type'] == 4)
		{ $title = 'Components Style'; }
		if($_REQUEST['type'] == 5)
		{ $title = 'Modules Style'; }
		if($_REQUEST['type'] == 6)
		{ $title = 'Borders Style'; }
		if($_REQUEST['type'] == 7)
		{ $title = 'Menu Style'; }
		if($_REQUEST['type'] == 8)
		{ $title = 'Typography Style'; }
	}
	require('components/common/toolbox.php'); 
?>
<div class="menu_top">
	<input type="hidden" name="action" value="editor_theme_css">
	<input type="hidden" name="css" value="<?php echo $item['id']; ?>" />
	<input type="hidden" name="type" value="<?php echo $_REQUEST['type']; ?>" />
    <?php if((($_REQUEST['type'] > 0) && ($_REQUEST['type'] < 4)) || ($_REQUEST['type'] == 6)): ?>
    <input type="hidden" id="load_css" name="load_css" value="0" />
    <?php endif; ?>
</div>
<fieldset>
	<dl>
		<dt><?php echo $title; ?></dt>
		<dd>
        <input type="submit" value="Save" style="padding-left:20px; padding-right:10px;  background-image: url('../images/system/save.gif'); border:1px solid #DDDDDD; height:20px;" 
        class="buttons" />
        <?php if((($_REQUEST['type'] > 0) && ($_REQUEST['type'] < 4)) || ($_REQUEST['type'] == 6)): ?>
        <input type="button" onmousedown="document.getElementById('load_css').value=<?php echo $_REQUEST['type']; ?>; submit();" value="Load Connected Css" style="padding-left:20px; padding-right:10px;  background-image: url('../images/system/process.gif'); border:1px solid #DDDDDD; height:20px;" 
        class="buttons">
        <?php endif; ?>
	  </dd>
	</dl>
	<?php if($_REQUEST['type'] < 1): ?>
	<dl>
		<dt>Standard Selectors:</dt>
		<dd>
			<select style="width:50%;" name="add_selector" onchange="new_selector.value=this.value;">
			<option value="0">Choose a selector to add</option>
			<?php 
				if($selectors)
				{
					foreach($selectors as $selector)
					{ 
						if(!$style[$selector['selector']])
						{ echo '<option value="'.$selector['selector'].'">'.$selector['selector'].'</option>'; }
					}
				}
			?>
			</select>
		</dd>
	</dl>
	<dl>
		<dt>Theme Layout Selectors:</dt>
		<dd>
			<select style="width:50%;" name="add_selector2" onchange="new_selector.value=this.value;">
			<option value="0">Choose a selector to add</option>
			<?php 
				if($selectors_theme)
				{
					foreach($selectors_theme as $selector)
					{ 
						if(!$style[$selector['selector']])
						{ echo '<option value="'.$selector['selector'].'">'.$selector['selector'].'</option>'; }
					}
				}
			?>
			</select>
		</dd>
	</dl>
	<?php endif; ?>
    <?php if($_REQUEST['type'] == 4): ?>
	<dl>
		<dt>Component Selectors:</dt>
		<dd>
			<select style="width:50%;" name="add_selector" onchange="new_selector.value=this.value;">
			<option value="0">Choose a selector to add</option>
			<?php 
				if($selectors_com)
				{
					foreach($selectors_com as $selector)
					{ 
						if(!$style[$selector['selector']])
						{ echo '<option value="'.$selector['selector'].'">'.$selector['selector'].'</option>'; }
					}
				}
			?>
			</select>
		</dd>
	</dl>
	<?php endif; ?>
    <?php if($_REQUEST['type'] == 5): ?>
	<dl>
		<dt>Module Selectors:</dt>
		<dd>
			<select style="width:50%;" name="add_selector" onchange="new_selector.value=this.value;">
			<option value="0">Choose a selector to add</option>
			<?php 
				if($selectors_mod)
				{
					foreach($selectors_mod as $selector)
					{ 
						if(!$style[$selector['selector']])
						{ echo '<option value="'.$selector['selector'].'">'.$selector['selector'].'</option>'; }
					}
				}
			?>
			</select>
		</dd>
	</dl>
	<?php endif; ?>
	<dl>
		<dt>
			<input type="submit" value="Add new selector" class="buttons" style="padding-left:20px; padding-right:10px;   background-image: url('../images/system/new.gif'); border:1px solid #DDDDDD;" /><br />
			<input name="new_selector" type="text" value="selector" onclick="if(this.value=='selector'){this.value='';}" />
			
		</dt>
		<dd>
			<textarea name="new_style" style="width:50%; height:120px;"></textarea>
			
		</dd>
	</dl>
</fieldset>
<div class="style_editor">
    <ul>
    	<?php 
		$styleList = getThemeStyleList($item['id'], $_REQUEST['type']);
		if($styleList)
		{
			$count = 0;
			foreach($styleList as $selector)
			{
			?>
            <li>
                <input style="cursor:pointer;" onclick="this.style.background='#CCCCCC'; swapDisplay('style_<?php echo($selector['id']); ?>');" name="selector[]" type="text" value="<?php echo($selector['selector']); ?>" /><br /><?php if($selector['bg_image'] != '') { echo $selector['bg_image']; } ?>
            </li>
            <li style="display: none;" id="style_<?php echo($selector['id']); ?>">
                <textarea rows="10" name="style[]"><?php echo($selector['style']); ?></textarea><br />
                <?php if(($_REQUEST['type'] < 1) || ($_REQUEST['type'] > 3)): ?>
                <input style="width:300px;" id="bg_<?php echo($selector['id']); ?>" type="file" name="bg_image[]" />
                <button name="upload" onclick="submit();">Upload</button>
                <?php endif; ?>
                <input type="submit" value="Save" style="padding-left:20px; padding-right:10px;  background-image: url('../images/system/save.gif'); border:1px solid #DDDDDD; height:20px; width:60px" class="buttons" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <button name="delete_selector" onclick="document.getElementById('delete_selector').value=<?php echo $selector['id']; ?>; submit();" >Delete</button>
                
                <input type="hidden" name="style_id[]" value="<?php echo $selector['id']; ?>" />
            </li>
			<?php
			$count++;
			}
		}
		?>
    </ul>
    <input type="hidden" id="delete_selector" name="delete_selector" value="0" />
</div>